home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / yk211src.lha / Yak_2.11_Src / WBStartup / CapShift.c < prev    next >
C/C++ Source or Header  |  1995-11-08  |  1KB  |  49 lines

  1. #include <devices/inputevent.h>
  2. #include <proto/exec.h>
  3. #include <proto/console.h>
  4.  
  5. #include <ctype.h>
  6.  
  7. #include "CapShift.h"
  8.  
  9. struct Library *ConsoleDevice;
  10.  
  11. void
  12. CapShiftFunction(struct InputEvent *ev)
  13. {
  14.     struct IOStdReq ioreq;
  15.     UBYTE           ansicode0, ansicode1;
  16.     UWORD           qual;
  17.  
  18.     /* Exclude Amiga commands */
  19.     if (!(ev->ie_Qualifier & (IEQUALIFIER_LCOMMAND|IEQUALIFIER_RCOMMAND)))
  20.     {
  21.         /* Open the console device just to do keymapping. (unit -1 means any unit) */
  22.         if (!OpenDevice("console.device", -1, (struct IORequest *)&ioreq, 0))
  23.         {
  24.             ConsoleDevice = (struct Library *)ioreq.io_Device;
  25.  
  26.             qual = ev->ie_Qualifier;
  27.  
  28.             /* Decode the RAWKEY event */
  29.             if (RawKeyConvert(ev, &ansicode0, 1, NULL) == 1)
  30.             {
  31.                 /* Translate printable character only */
  32.                 if (isprint(ansicode0))
  33.                 {
  34.                     /* Get the unshifted code */
  35.                     ev->ie_Qualifier &= ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT);
  36.                     RawKeyConvert(ev, &ansicode1, 1, NULL);
  37.  
  38.                     if (ansicode0 == ansicode1) /* Unlock the CapsLock */
  39.                         ev->ie_Qualifier = qual & ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT | IEQUALIFIER_CAPSLOCK);
  40.                     else
  41.                         ev->ie_Qualifier = qual;
  42.                 }
  43.             }
  44.  
  45.             CloseDevice((struct IORequest *)&ioreq);
  46.         }
  47.     }
  48. }
  49.